<?php

namespace app\admin\controller;

use app\admin\service\AirportService;

class AirportController extends CommonController
{
    // 获取所有可用的机场
    public function getAirportAll(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(AirportService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getAll();
        return $this->return_result($this->returnData);
    }

    // 获取机场数据的分页列表
    public function getAirportList(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(AirportService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getList();
        return $this->return_result($this->returnData);
    }

    // 添加机场
    public function toAddAirport(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(AirportService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toAdd();
        return $this->return_result($this->returnData);
    }

    // 更新机场
    public function toUpdateAirport(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(AirportService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toUpdate();
        return $this->return_result($this->returnData);
    }

    // 机场的详细内容
    public function getAirportDetail(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(AirportService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getDetail();
        return $this->return_result($this->returnData);
    }

    // 删除机场
    public function toDelAirport(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(AirportService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->toDel();
        return $this->return_result($this->returnData);
    }

}